import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import 'url-polyfill';
import { Base64Util } from './utils/base64-util';
import { RuntimeUtils } from './utils/runtime-util';

Vue.use(ElementUI);

Vue.config.productionTip = false;

const iframeUrl = new URL(window.location.href);
const searchParam = iframeUrl.searchParams;
const bimboxContext = searchParam.get('bimbox-context');
if (bimboxContext && bimboxContext.length) {
    const envParams = JSON.parse(Base64Util.decodeUrn(bimboxContext));
    RuntimeUtils.init(envParams);
} else {
    console.error('BIMBox的运行环境信息未设置，应用会无法正常运行！');
}

new Vue({
    router,
    store,
    render: (h) => h(App),
}).$mount('#app');
